//
//  RCUserVCMyPhotosCell.m
//  RocketProject
//
//  Created by chen jiedan on 13-8-25.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCUserVCMyPhotosCell.h"
#import "UIImageView+WebCache.h"
#import "UIImageView+Extented.h"
#import "CommonDefines.h"
#import "UIColor-Expanded.h"
#import "NSString+NSString_Ex_.h"
#import "UIButton+WebCache.h"



@implementation RCUserVCMyPhotosCell{
    UIButton *_leftImageView;
    UILabel     *_leftText;
    UILabel     *_leftPrice;
    UIView      *_leftStartView;
//    RCMyPhotosItemDataModel *leftModel;
    
    
    UIButton *_rightImageView;
    UILabel     *_rightText;
    UILabel     *_rightPrice;
    UIView      *_rightStartView;
//    RCMyPhotosItemDataModel *rightModel;

}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self createPlaceHolder];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void) leftClick
{
    
}

- (void) rightClick
{
    
}

- (void) createPlaceHolder
{
    _leftImageView = [[UIButton alloc] initWithFrame:CGRectMake(20, 20, 130, 80)];
    [self.contentView addSubview:_leftImageView];
    [_leftImageView addTarget:self action:@selector(leftClick) forControlEvents:UIControlEventTouchUpInside];
    [_leftImageView release];
    
    _leftText = [[UILabel alloc] initWithFrame:CGRectMake(20, 110, 80, 15)];
    [self.contentView addSubview:_leftText];
    _leftText.backgroundColor = [UIColor clearColor];
    _leftText.textColor = kNormalHeadTextColor;
    _leftText.font = [UIFont fontWithName:kFontNameHelvetica size:15];
    [_leftText release];
    
    _leftPrice = [[UILabel alloc] initWithFrame:CGRectMake(100, 110, 80, 15)];
    [self.contentView addSubview:_leftPrice];
    _leftPrice.backgroundColor = [UIColor clearColor];
    _leftPrice.font = [UIFont fontWithName:kFontNameHelvetica size:12];
    _leftPrice.textColor = kNormalTextColor;
    [_leftPrice release];
    
    
    _leftStartView = [[UIView alloc] initWithFrame:CGRectMake(20, 130, 80, 30)];
    [self.contentView addSubview:_leftStartView];
    [_leftStartView release];
    
    
    _rightImageView = [[UIButton alloc] initWithFrame:CGRectMake(20+160, 20, 130, 80)];
    [self.contentView addSubview:_rightImageView];
    [_rightImageView addTarget:self action:@selector(rightClick) forControlEvents:UIControlEventTouchUpInside];
    [_rightImageView release];
    
    _rightText = [[UILabel alloc] initWithFrame:CGRectMake(20+160, 110, 80, 15)];
    [self.contentView addSubview:_rightText];
    _rightText.backgroundColor = [UIColor clearColor];
    _rightText.textColor = kNormalHeadTextColor;
    _rightText.font = [UIFont fontWithName:kFontNameHelvetica size:15];
    [_rightText release];
    
    _rightPrice = [[UILabel alloc] initWithFrame:CGRectMake(90+160,110, 80, 15)];
    [self.contentView addSubview:_rightPrice];
    _rightPrice.backgroundColor = [UIColor clearColor];
    _rightPrice.font = [UIFont fontWithName:kFontNameHelvetica size:12];
    _rightPrice.textColor = kNormalTextColor;
    [_rightPrice release];
    
    
    _rightStartView = [[UIView alloc] initWithFrame:CGRectMake(20+160, 130, 80, 30)];
    [self.contentView addSubview:_rightStartView];
    [_rightStartView release];
    
}


- (void) bindData:(RCMyPhotosItemDataModel*)leftItem withRight:(RCMyPhotosItemDataModel *)rightItem
{
    if (leftItem == nil) {
        return;
    }
    
    UIImage *img = [UIImage imageNamed:@"icon_RCUserVCPhotoListIMG"];
//    [_leftImageView autoResizeToSetImage:img];
    if (![NSString stringIsNullOrEmpty:leftItem.picUrl]) {
        [_leftImageView setImageWithURL:[NSURL URLWithString:leftItem.picUrl] placeholderImage:img];
    }

    for (UIView *subView in _leftStartView.subviews) {
        [subView removeFromSuperview];
    }
    
//    for (int i = 0; i < 5; i++) {
//        UIImageView *t = [[UIImageView alloc] initWithFrame:CGRectMake(12*i, 0 ,10, 10)];
//        if (3 > i) {
//            [t setImage:[UIImage imageNamed:@"start_highlight"]];
//        }else{
//            [t setImage:[UIImage imageNamed:@"start_normal"]];
//        }
//        [_leftStartView addSubview:t];
//        [t release];
//    }
    _leftText.text = leftItem.title;
//    _leftPrice.text = @"100元--未定义";
    

    if (rightItem == nil) {
        _rightImageView.hidden = YES;
        _rightStartView.hidden = YES;
        _rightText.hidden = YES;
        _rightPrice.hidden = YES;
        return;
    }else{
        _rightImageView.hidden = NO;
        _rightStartView.hidden = NO;
        _rightText.hidden = NO;
        _rightPrice.hidden = NO;
    }
    
    if (![NSString stringIsNullOrEmpty:rightItem.picUrl]) {
        [_rightImageView setImageWithURL:[NSURL URLWithString:rightItem.picUrl] placeholderImage:img];
    }
    
    for (UIView *subView in _rightStartView.subviews) {
        [subView removeFromSuperview];
    }
//    for (int i = 0; i < 5; i++) {
//        UIImageView *t = [[UIImageView alloc] initWithFrame:CGRectMake(12*i, 0 ,10, 10)];
//        if (3 > i) {
//            [t setImage:[UIImage imageNamed:@"start_highlight"]];
//        }else{
//            [t setImage:[UIImage imageNamed:@"start_normal"]];
//        }
//        [_rightStartView addSubview:t];
//        [t release];
//    }
    
    _rightText.text = rightItem.title;
//    _rightPrice.text = @"100元";

}

- (void) dealloc
{
//    KF_RELEASE_SAFELY(leftModel);
//    KF_RELEASE_SAFELY(rightModel);
    [super dealloc];
}
@end


//
